define([
	'jquery', 'bootstrap', 'frontend', 'form', 'template', 'vue',
	'./../components/ohcard/identify/api',
	'./../components/ohcard/identify/index',
    './../components/ohcard/identify/header/index',
    './../components/ohcard/identify/step/index',
    './../components/ohcard/identify/step1/index',
    './../components/ohcard/identify/step2/index',
    './../components/ohcard/identify/step3/index',
], function (
	$, undefined, Frontend, Form, Template, Vue,
	api,
	ohcard,
	OhcardHeader,
	OhcardStep,
	OhcardStep1, OhcardStep2, OhcardStep3
) {
    var validatoroptions = {
        invalid: function (form, errors) {
            $.each(errors, function (i, j) {
                Layer.msg(j);
            });
        },
        ignore: ':hidden'
    };
    var Controller = {
        create: function () {
            //本地验证未通过时提示
            $("#create-form").data("validator-options", validatoroptions);

            //为表单绑定事件
            Form.api.bindevent($("#create-form"), function (data, ret) {
				location.href = ret.url;
                return false;
			});
        },
	    room: function(){
			const {
				ref,
				provide,
				computed,
				watch,
				onMounted,
				toRef,
				defineComponent,
			} = Vue

		    const app = Vue.createApp({
			    setup(){
					const room_id = Config.room_id;
					let room = ref(false);
					const explainData = ref({
						tip: true,
					})
				    const currentTemplate = ref(computed(() => 'OhcardStep' + room.value.step));
					const appPaddingBottom = ref('20px');
					provide('appPaddingBottom',appPaddingBottom);

					onMounted(async () => {
						await api.getRoom(room_id).then(res => {
							room.value = res.data;
						}).catch(error => {
							Layer.alert('房间不存在',{title:false,icon:2,yes:()=>{window.location.href = error.url}})
							console.log(error)
						})
					});

				    return {
						room,
					    explainData,
					    currentTemplate,
					    appPaddingBottom,
				    };
			    }
		    });

		    app.component('OhcardHeader', OhcardHeader);
		    app.component('OhcardStep', OhcardStep);
		    app.component('OhcardStep1', OhcardStep1);
		    app.component('OhcardStep2', OhcardStep2);
		    app.component('OhcardStep3', OhcardStep3);

		    app.mount('#app');
	    }
    };
    return Controller;
});
